package com.kiven.thread;

import java.lang.*;

public class InteruptThread implements Runnable {
	@Override
	public void run() {
		int index = 0;
		while(true) {
			System.out.println("线程运行");
			
			try {
				Thread.currentThread().sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			
			if((index++)==10) {
					this.notify();
			}
		}
	}

	public static void main(String[] args) {
		Thread t = new Thread(new InteruptThread());
		t.start();
		
		for(int i=0; i<1000; i++) {
			System.out.println("i值：" + i);
			System.out.println("每次循环让线程等待1妙");
			System.out.println("当前线程名：" + Thread.currentThread().getName());
			
			
			if(i == 10) {
				try {
					System.out.println("此时InteruptThread进入等待状态，此时的i=" + i);
					Thread.currentThread().wait();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
			
			
			
		}
	}
}


